package net.pm.core.aspect;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

/**
 * 订单状态改变记录
 * @author shizeyuan
 *
 */
@Aspect
@Component
public class PM_04_OrderinfologAspect {
	
	
	@AfterReturning(value="@annotation(net.pm.core.annotation.OrderinfoLog)",returning="retval")
	public void hasChangeRecord(Object retval){
		
	}
	
	/**
	 * 无聊统计下代码行数
	 * @param args
	 */
	public static void main(String[] args) {
		String path = "/home/shizeyuan/workspace/pmpro";
		countFile(path);
		System.out.println(codelinecount);
		System.out.println(filecount);
	}
	
	private static int codelinecount = 0;
	private static int filecount = 0;
	public static void countFile(String path){
		File file = new File(path);
		File[] files = file.listFiles();
		for(File f : files){
			if(f.isDirectory()){
				countFile(f.getAbsolutePath());  //递归
			}
			else{
				if(f.getName().endsWith(".java") || f.getName().endsWith(".ftl") ){
				System.out.println(f.getName());
				filecount++;
					try {
						InputStreamReader isreader = new InputStreamReader(new FileInputStream(f));
						BufferedReader reader = new BufferedReader(isreader);
						String str = null;
						while((str = reader.readLine()) != null){
							System.out.println(str);
							codelinecount++;
						}
					} catch (FileNotFoundException e) {
						e.printStackTrace();
					} catch (IOException e) {
						e.printStackTrace();
					}
					
				}
			}
		}
	}

}
